package cn.com.bluemoon.daps.common.datascope.sign;

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 *  过滤器注册配置类
 * @author Lilike on 2022/2/21
 */
@Configuration
@ConditionalOnProperty(
        value = {"bm.dap.api.sign.auth.enabled"},
        matchIfMissing = false
)
public class ApiSignAuthFilterConfig {

    @Bean
    public FilterRegistrationBean registFilter(SignProperties signProperties) {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        ApiSignAuthFilter filter = new ApiSignAuthFilter();
        filter.setSignProperties(signProperties);
        registration.setFilter(filter);
        registration.addUrlPatterns(signProperties.getUrlPatterns());
        registration.setName(ApiSignAuthFilter.class.getName());
        registration.setOrder(5);
        return registration;
    }

}
